#pragma once
/*****************************************************************************************************************
 * Filename           : MedoidShift.h
 * Description        : Header file for MedoidShift.cpp
*****************************************************************************************************************/

/* Define to prevent recursive inclusion -----------------------------------------------------------------------*/
#ifndef __QUICK_SHIFT_H
#define __QUICK_SHIFT_H

/* Includes ----------------------------------------------------------------------------------------------------*/
#include <vector>
#include <opencv2\opencv.hpp>

/* Exported macro ----------------------------------------------------------------------------------------------*/
#define QUICKSHIFT_INF 0XFFFFFFFF /** Quick shift infinity constant */

/* Exported types ----------------------------------------------------------------------------------------------*/
typedef std::vector<std::vector<double>> vector2D;
typedef std::vector<std::vector<uint32_t>> vector2L;


/* Exported constants ------------------------------------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------------------------------------------*/

class QuickShift
{
public:
	QuickShift(double ratio, double kernelSize, double maxDist);
	cv::Mat QuickShiftSegment(cv::Mat& srcImg, vector2L& pntIdxArr, vector2D& distMat);

private:
	vector2D BuildWeightMatrix(cv::Mat& srcImg, double sigma);
	void ImgSegment(cv::Mat& srcImg, vector2L& pntIdxArray, vector2D& distMat);
	void LabelImage(cv::Mat& srcImg, vector2L& labels, std::vector<uint32_t>& medoid);
	double CalPointsDist(cv::Mat& srcImg, int pts1RowIdx, int pts2RowIdx, int pts1ColIdx, int pts2ColIdx);
	void FindBestNeighbors(cv::Mat& srcImg, vector2D& weightMat, vector2L& parentMat, vector2D& distMat, double maxDist);
	void QuickShiftProcess(cv::Mat& srcImg, double kernelSize, double maxDist, vector2D& gapLenMat, vector2L& pntIdxArr);

	double m_ratio;
	double m_maxDist;
	double m_kernelSize;
};


#endif    /* __QUICK_SHIFT_H                                                                                    */

/***********************************************  END OF FILE  **************************************************/

